# leetcode 2216 美化数组的最小删除数

class Solution:
    def minDeletion(self, nums: List[int]) -> int:
        res = [nums[0]]
        res_index = 0
        for i in range(1, len(nums)):
            if res_index % 2 == 0 and nums[i] == res[-1]:
                continue
            else:
                res.append(nums[i])
                res_index += 1
        ret = len(nums) - len(res)
        if len(res) % 2 == 0:
            return ret
        return ret + 1
